package cn.kgb.dao;

import cn.kgb.javabean.WeatherReportUser;
import cn.kgb.util.DataAccess;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class WeatherReportUserDAO
{
  public List getAllUserList()
  {
    Connection con = DataAccess.getConnection();
    String sql = "SELECT * FROM myjavamail_weather_report_service_user l order by l.id";
    List list = new ArrayList();
    Statement stmt = null;
    try {
      stmt = con.createStatement();
      ResultSet rs = stmt.executeQuery(sql);
      while (rs.next()) {
        WeatherReportUser user = new WeatherReportUser();
        user.setId(rs.getInt("id"));
        user.setUsername(rs.getString("username"));
        user.setEmail(rs.getString("email"));
        user.setPhonenumber(rs.getString("phone"));
        user.setSerives(rs.getString("services"));
        list.add(user);
      }
      rs.close();
      stmt.close();
      con.close();
    }
    catch (SQLException e) {
      e.printStackTrace();
    } finally {
      if (stmt != null) {
        try {
          stmt.close();
        } catch (Exception localException2) {
        }
        stmt = null;
      }
      if (con != null) {
        try {
          con.close();
        } catch (Exception localException3) {
        }
        con = null;
      }
    }
    return list;
  }
}